<!DOCTYPE html>


  <html class="dark page-post">


<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  
  <title>学会使用Graphviz绘制流程图 | Poetry&#39;s Blog</title>

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  
    <meta name="keywords" content="Graphviz,">
  

  <meta name="description" content="一、初识Graphviz1.1 简介 GraphViz是一个开源的图像可视化的软件，是贝尔实验室开发的一个开源的工具包，它使用一个特定的DSL(领域特定语言): dot作为脚本语言，然后使用布局引擎来解析此脚本，并完成自动布局。graphviz提供丰富的导出格式，如常用的图片格式，SVG，PDF格式等  1.2 环境搭建结合sublime Text插件实时编译预览  使用shift+command">
<meta name="keywords" content="Graphviz">
<meta property="og:type" content="article">
<meta property="og:title" content="学会使用Graphviz绘制流程图">
<meta property="og:url" content="http://blog.poetries.top/2018/09/17/graphviz/index.html">
<meta property="og:site_name" content="Poetry&#39;s Blog">
<meta property="og:description" content="一、初识Graphviz1.1 简介 GraphViz是一个开源的图像可视化的软件，是贝尔实验室开发的一个开源的工具包，它使用一个特定的DSL(领域特定语言): dot作为脚本语言，然后使用布局引擎来解析此脚本，并完成自动布局。graphviz提供丰富的导出格式，如常用的图片格式，SVG，PDF格式等  1.2 环境搭建结合sublime Text插件实时编译预览  使用shift+command">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/208.png">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/1124873-67688cd634d43522.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/209.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/210.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/211.jpg">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/212.jpg">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/213.jpg">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/214.jpg">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/215.jpg">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/216.jpg">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/217.jpg">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/218.jpg">
<meta property="og:image" content="http://img2.tuicool.com/yEze6z.png%21web">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/219.jpg">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/220.jpg">
<meta property="og:updated_time" content="2020-08-15T04:25:31.910Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="学会使用Graphviz绘制流程图">
<meta name="twitter:description" content="一、初识Graphviz1.1 简介 GraphViz是一个开源的图像可视化的软件，是贝尔实验室开发的一个开源的工具包，它使用一个特定的DSL(领域特定语言): dot作为脚本语言，然后使用布局引擎来解析此脚本，并完成自动布局。graphviz提供丰富的导出格式，如常用的图片格式，SVG，PDF格式等  1.2 环境搭建结合sublime Text插件实时编译预览  使用shift+command">
<meta name="twitter:image" content="https://poetries1.gitee.io/img-repo/2019/10/208.png">

  

  
    <link rel="icon" href="/favicon.ico">
  

  <link href="/css/styles.css?v=c114cbeddx" rel="stylesheet">
<link href="/css/other.css?v=c114cbeddx" rel="stylesheet">


  
    <link rel="stylesheet" href="/css/personal-style.css">
  

  

  
  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?40b1f89aa80f2527b3db779c6898c879";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>


  
  <script type="text/javascript">
	(function(){
	    var bp = document.createElement('script');
	    var curProtocol = window.location.protocol.split(':')[0];
	    if (curProtocol === 'https') {
	        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
	    }
	    else {
	        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
	    }
	    var s = document.getElementsByTagName("script")[0];
	    s.parentNode.insertBefore(bp, s);
	})();
  </script>



  
    <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.3.0/css/font-awesome.min.css">
  

  <!-- 聊天系统 -->
  
    
   <link type="text/css" rel="stylesheet" href="/renxi/default.css">
   <style>
      #modal {
        position: static !important;
      }
      .filter {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        background: #fe5757;
        animation: colorChange 30s ease-in-out infinite;
        animation-fill-mode: both;
        mix-blend-mode: overlay;
      }
  
      @keyframes colorChange {
        0%, 100% {
            opacity: 0;
        }
        50% {
            opacity: .9;
        }
      }
   </style>
</head>
</html>
<body>
  
  
    <span id="toolbox-mobile" class="toolbox-mobile">导航</span>
  

  <div class="post-header CENTER">
   
  <div class="toolbox">
    <a class="toolbox-entry" href="/">
      <span class="toolbox-entry-text">导航</span>
      <i class="icon-angle-down"></i>
      <i class="icon-home"></i>
    </a>
    <ul class="list-toolbox">
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/archives/"
            rel="noopener noreferrer"
            target="_self"
            >
            博客
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/categories/"
            rel="noopener noreferrer"
            target="_self"
            >
            分类
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/tags/"
            rel="noopener noreferrer"
            target="_self"
            >
            标签
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/search/"
            rel="noopener noreferrer"
            target="_self"
            >
            搜索
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/link/"
            rel="noopener noreferrer"
            target="_self"
            >
            友链
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/about/"
            rel="noopener noreferrer"
            target="_self"
            >
            关于
          </a>
        </li>
      
    </ul>
  </div>


</div>


  <div id="toc" class="toc-article">
    <strong class="toc-title">文章目录<i class="iconfont toc-title" style="display:inline-block;color:#87998d;width:20px;height:20px;">&#xf004b;</i></strong>
    <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#一、初识Graphviz"><span class="toc-text">一、初识Graphviz</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-简介"><span class="toc-text">1.1 简介</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-环境搭建"><span class="toc-text">1.2 环境搭建</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#二、使用"><span class="toc-text">二、使用</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#2-1-第一个graphviz图"><span class="toc-text">2.1 第一个graphviz图</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-2-带标签"><span class="toc-text">2.2 带标签</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-3-子视图"><span class="toc-text">2.3 子视图</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-4-结构视图"><span class="toc-text">2.4 结构视图</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-5-树形结构"><span class="toc-text">2.5 树形结构</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-6-时序图"><span class="toc-text">2.6 时序图</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-7-一个hash表的数据结构"><span class="toc-text">2.7 一个hash表的数据结构</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-8-模块的生命周期图"><span class="toc-text">2.8 模块的生命周期图</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-9-简单的UML类图"><span class="toc-text">2.9 简单的UML类图</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-10-有限状态机"><span class="toc-text">2.10 有限状态机</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#三、语法"><span class="toc-text">三、语法</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#3-1-图像属性"><span class="toc-text">3.1 图像属性</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-2-交点属性"><span class="toc-text">3.2 交点属性</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-3-边的属性"><span class="toc-text">3.3 边的属性</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-4-尺寸-背景颜色"><span class="toc-text">3.4 尺寸, 背景颜色</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#四、一些技巧"><span class="toc-text">四、一些技巧</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#4-1-插入图片"><span class="toc-text">4.1 插入图片</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-2-统一节点和连线"><span class="toc-text">4.2 统一节点和连线</span></a></li></ol></li></ol>
  </div>
  




<div class="content content-post CENTER">
   <!-- canvas 彩带 -->
<canvas id="evanyou" width="1302" height="678" style="position: fixed;width: 100%;height: 100%;top: 0;left:0;z-index:-1;"></canvas>

<article id="post-graphviz" class="article article-type-post" itemprop="blogPost">
  <header class="article-header" style="position:relative;">
    <h1 class="post-title">学会使用Graphviz绘制流程图</h1>

    <div class="article-meta">
      <span>
        <i class="icon-calendar"></i>
        <span>2018.09.17</span>
      </span>

      
        <span class="article-author">
          <i class="icon-user"></i>
          <span>Poetry</span>
        </span>
      

      
  <span class="article-category">
    <i class="icon-list"></i>
    <a class="article-category-link" href="/categories/Front-End/">Front-End</a>
  </span>



      

      
      <i class="fa fa-eye"></i> 
        <span id="busuanzi_container_page_pv">
           &nbsp热度 <span id="busuanzi_value_page_pv">
           <i class="fa fa-spinner fa-spin"></i></span>℃
        </span>
      
      
       
          <span class="post-count">
            <i class="fa fa-file-word-o"></i>&nbsp
            <span>字数统计 2k字</span>
          </span>

          <span class="post-count">
            <i class="fa fa-columns"></i>&nbsp
            <span>阅读时长 10分</span>
          </span>
      
      
    </div>

    <i class="iconfont" id="toc-eye" style="display:inline-block;color:#b36619;position:absolute;top:0;right:0;cursor:pointer;
    font-size: 24px;">&#xe61c;</i>

  </header>

  <div class="article-content">
    
      <div id="container">
        <h2 id="一、初识Graphviz"><a href="#一、初识Graphviz" class="headerlink" title="一、初识Graphviz"></a>一、初识Graphviz</h2><h3 id="1-1-简介"><a href="#1-1-简介" class="headerlink" title="1.1 简介"></a>1.1 简介</h3><blockquote>
<p><code>GraphViz</code>是一个开源的图像可视化的软件，是贝尔实验室开发的一个开源的工具包，它使用一个特定的<code>DSL</code>(领域特定语言): <code>dot</code>作为脚本语言，然后使用布局引擎来解析此脚本，并完成自动布局。<code>graphviz</code>提供丰富的导出格式，如常用的图片格式，<code>SVG</code>，<code>PDF</code>格式等</p>
</blockquote>
<h3 id="1-2-环境搭建"><a href="#1-2-环境搭建" class="headerlink" title="1.2 环境搭建"></a>1.2 环境搭建</h3><p><strong>结合sublime Text插件实时编译预览</strong></p>
<blockquote>
<p>使用<code>shift+command+p</code>，输入搜索选中<code>Package Control: Install Package</code>,然后输入<code>GraphViz</code>,然后安装<code>GraphVizPreview</code>即可，安装完成后，只要全选中代码，然后按<code>shift+command+g</code>就可以预览了。</p>
</blockquote>
<ul>
<li>其实也可以直接用<code>brew</code>安装<code>GraphViz</code>,但是每次要敲命令行，太麻烦了</li>
</ul>
<p><strong><code>mac</code>下执行</strong></p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">brew install graphviz</span><br></pre></td></tr></table></figure>
<blockquote>
<p>终端编译代码 <code>dot test.dot -T png -o test.png</code></p>
</blockquote>
<h2 id="二、使用"><a href="#二、使用" class="headerlink" title="二、使用"></a>二、使用</h2><blockquote>
<p><code>Graphviz</code> 支持两类图：无向图（<code>graph</code>,用“ <code>- -</code> ”表示节点之间）和 有向图（<code>digraph</code>,用“ <code>-&gt;</code>” 表示节点之间）。graphviz包含3中元素，图，顶点和边。<strong>每个元素都可以具有各自的属性，用来定义字体，样式，颜色，形状等</strong></p>
</blockquote>
<p><strong><code>GraphViz</code>中包含多种布局</strong></p>
<ul>
<li><code>dot</code> 默认布局，用于有向图</li>
<li><code>neato</code> 基于<code>spring-model</code>算法(<code>force-based</code>)</li>
<li><code>twopo</code> 径向布局</li>
<li><code>circo</code> 圆形布局</li>
<li><code>fdp</code> 用于无向图</li>
</ul>
<h3 id="2-1-第一个graphviz图"><a href="#2-1-第一个graphviz图" class="headerlink" title="2.1 第一个graphviz图"></a>2.1 第一个graphviz图</h3><blockquote>
<p>语法介绍 <a href="http://graphs.grevian.org/reference" target="_blank" rel="noopener">http://graphs.grevian.org/reference</a></p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">digraph abc&#123;</span><br><span class="line">  a;</span><br><span class="line">  b;</span><br><span class="line">  c;</span><br><span class="line">  d;</span><br><span class="line"> </span><br><span class="line">  a -&gt; b;</span><br><span class="line">  b -&gt; d;</span><br><span class="line">  c -&gt; d;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://poetries1.gitee.io/img-repo/2019/10/208.png" alt></p>
<p><strong>定义顶点和边的样式</strong></p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">digraph abc&#123;</span><br><span class="line">  node [shape=&quot;record&quot;];</span><br><span class="line">  edge [style=&quot;dashed&quot;];</span><br><span class="line">  a;</span><br><span class="line">  b;</span><br><span class="line">  c;</span><br><span class="line">  d;</span><br><span class="line"> </span><br><span class="line">  a -&gt; b;</span><br><span class="line">  b -&gt; d;</span><br><span class="line">  c -&gt; d;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://upload-images.jianshu.io/upload_images/1124873-67688cd634d43522.png" alt></p>
<blockquote>
<p>进一步修改顶点和边样式,将顶点<code>a</code>的颜色改为淡绿色，并将<code>c</code>到<code>d</code>的边改为红色</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">digraph abc&#123;</span><br><span class="line">  node [shape=&quot;record&quot;];</span><br><span class="line">  edge [style=&quot;dashed&quot;];</span><br><span class="line"> </span><br><span class="line">  a [style=&quot;filled&quot;, color=&quot;black&quot;, fillcolor=&quot;chartreuse&quot;];</span><br><span class="line">  b;</span><br><span class="line">  c;</span><br><span class="line">  d;</span><br><span class="line"> </span><br><span class="line">  a -&gt; b;</span><br><span class="line">  b -&gt; d;</span><br><span class="line">  c -&gt; d [color=&quot;red&quot;];</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://poetries1.gitee.io/img-repo/2019/10/209.png" alt></p>
<p>其他例子</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">digraph demo&#123;</span><br><span class="line">  label=&quot;儿茶酚胺合成代谢路径&quot;;</span><br><span class="line"></span><br><span class="line">  酪氨酸 -&gt; L多巴 -&gt; 多巴胺 -&gt; 去甲肾上腺素 -&gt; 肾上腺素;</span><br><span class="line"></span><br><span class="line">  下丘脑 -&gt; 多巴胺;</span><br><span class="line">  交感神经元 -&gt; 去甲肾上腺素;</span><br><span class="line">  肾上腺髓质 -&gt; 去甲肾上腺素,肾上腺素;</span><br><span class="line"></span><br><span class="line">  酪氨酸 [label=&quot;酪氨酸&quot;,color=green];</span><br><span class="line">  多巴胺 [label=&quot;多巴胺&quot;, color=red];</span><br><span class="line">  肾上腺素 [label=&quot;肾上腺素&quot;, color=red];</span><br><span class="line"></span><br><span class="line">  下丘脑 [shape=box];</span><br><span class="line">  交感神经元 [shape=box];</span><br><span class="line">  肾上腺髓质 [shape=box];</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://poetries1.gitee.io/img-repo/2019/10/210.png" alt></p>
<h3 id="2-2-带标签"><a href="#2-2-带标签" class="headerlink" title="2.2 带标签"></a>2.2 带标签</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">digraph &#123;</span><br><span class="line"></span><br><span class="line">    player[label = &quot;player&quot;, color = Blue, fontcolor = Red, fontsize = 24, shape = box];</span><br><span class="line">    game[label = &quot;game&quot;, color = Red, fontcolor = Blue, fontsize = 24, shape = ellipse];</span><br><span class="line"></span><br><span class="line">    player -&gt; game[label = &quot;play&quot;]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://poetries1.gitee.io/img-repo/2019/10/211.jpg" alt></p>
<h3 id="2-3-子视图"><a href="#2-3-子视图" class="headerlink" title="2.3 子视图"></a>2.3 子视图</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">digraph &#123;</span><br><span class="line"></span><br><span class="line">    label = visitNet</span><br><span class="line"></span><br><span class="line">    rankdir = LR</span><br><span class="line"></span><br><span class="line">    node[color = Red, fontsize = 24, shape = box]</span><br><span class="line">    edge[color = Blue, style = &quot;dashed&quot;]</span><br><span class="line"></span><br><span class="line">    user[style = &quot;filled&quot;, color = &quot;yellow&quot;, fillcolor = &quot;chartreuse&quot;]</span><br><span class="line">    subgraph cluster_cd&#123;</span><br><span class="line">        label = &quot;server and browser&quot;</span><br><span class="line">        bgcolor = green;</span><br><span class="line"></span><br><span class="line">        browser -&gt; server</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    user -&gt; computer;</span><br><span class="line">    computer -&gt; browser;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://poetries1.gitee.io/img-repo/2019/10/212.jpg" alt></p>
<h3 id="2-4-结构视图"><a href="#2-4-结构视图" class="headerlink" title="2.4 结构视图"></a>2.4 结构视图</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">digraph &#123;</span><br><span class="line"></span><br><span class="line">    node[shape = record];</span><br><span class="line">    struct1[label = &quot;&lt;f0&gt; left|&lt;f1&gt; mid&amp;#92; dle|&lt;f2&gt; right&quot;];</span><br><span class="line">    struct2[label = &quot;&lt;f0&gt; one|&lt;f1&gt; two&quot;];</span><br><span class="line">    struct3[label = &quot;hello&amp;#92;nworld | &#123;b|&#123;c|&lt;here&gt; d|e&#125;|f&#125;|g|h&quot;];</span><br><span class="line">    struct1:f1 -&gt; struct2:f0;</span><br><span class="line">    struct1:f2 -&gt; struct3:here;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://poetries1.gitee.io/img-repo/2019/10/213.jpg" alt></p>
<h3 id="2-5-树形结构"><a href="#2-5-树形结构" class="headerlink" title="2.5 树形结构"></a>2.5 树形结构</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">digraph tree &#123;</span><br><span class="line">  </span><br><span class="line">  fontname = &quot;PingFang-SC-Light&quot;</span><br><span class="line">  fontsize = 24</span><br><span class="line"></span><br><span class="line">  node[shape = &quot;plaintext&quot;]</span><br><span class="line"></span><br><span class="line">  1 -&gt; 2;</span><br><span class="line">  1 -&gt; 3;</span><br><span class="line">  2 -&gt; 4;</span><br><span class="line">  2 -&gt; 5;</span><br><span class="line">  3 -&gt; 6;</span><br><span class="line">  3 -&gt; 7;</span><br><span class="line">  4 -&gt; 8;</span><br><span class="line">  4 -&gt; 9;</span><br><span class="line">  5 -&gt; 10;</span><br><span class="line">  5 -&gt; 11;</span><br><span class="line">  6 -&gt; 12;</span><br><span class="line">  6 -&gt; 13;</span><br><span class="line">  7 -&gt; 14;</span><br><span class="line">  7 -&gt; 15;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://poetries1.gitee.io/img-repo/2019/10/214.jpg" alt></p>
<h3 id="2-6-时序图"><a href="#2-6-时序图" class="headerlink" title="2.6 时序图"></a>2.6 时序图</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">digraph time &#123;</span><br><span class="line"></span><br><span class="line">    rankdir = &quot;LR&quot;;</span><br><span class="line">    node[shape = &quot;point&quot;, width = 0, height = 0];</span><br><span class="line">    edge[arrowhead = &quot;none&quot;, style = &quot;dashed&quot;];</span><br><span class="line"></span><br><span class="line">    &#123;</span><br><span class="line">        rank = &quot;same&quot;</span><br><span class="line">        edge[style = &quot;solided&quot;];</span><br><span class="line">        APP[shape = &quot;plaintext&quot;];</span><br><span class="line">        APP -&gt; step00 -&gt; step01 -&gt; step02 -&gt; step03 -&gt; step04 -&gt; step05;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    &#123;</span><br><span class="line">        rank=&quot;same&quot;;</span><br><span class="line">        edge[style=&quot;solided&quot;];</span><br><span class="line">        SDK[shape=&quot;plaintext&quot;];</span><br><span class="line">        SDK -&gt; step10 -&gt; step11 -&gt; step12 -&gt; step13 -&gt; step14 -&gt; step15;</span><br><span class="line">    &#125;</span><br><span class="line">    &#123;</span><br><span class="line">        rank=&quot;same&quot;;</span><br><span class="line">        edge[style=&quot;solided&quot;];</span><br><span class="line">        AliPay[shape=&quot;plaintext&quot;];</span><br><span class="line">        AliPay -&gt; step20 -&gt; step21 -&gt; step22 -&gt; step23 -&gt; step24 -&gt; step25;</span><br><span class="line">    &#125;</span><br><span class="line">    &#123;</span><br><span class="line">        rank=&quot;same&quot;;</span><br><span class="line">        edge[style=&quot;solided&quot;];</span><br><span class="line">        Server[shape=&quot;plaintext&quot;];</span><br><span class="line">        Server -&gt; step30 -&gt; step31 -&gt; step32 -&gt; step33 -&gt; step34 -&gt; step35;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    step00 -&gt; step10 [label=&quot;sends order info&quot;, arrowhead=&quot;normal&quot;];</span><br><span class="line">    step11 -&gt; step21 [label=&quot;open AliPay&quot;, arrowhead=&quot;normal&quot;];</span><br><span class="line">    step22 -&gt; step12 [label=&quot;pay success&quot;, arrowhead=&quot;normal&quot;];</span><br><span class="line">    step13 -&gt; step03 [label=&quot;pay success&quot;, arrowhead=&quot;normal&quot;];</span><br><span class="line">    step24 -&gt; step34 [label=&quot;pay success&quot;, arrowhead=&quot;normal&quot;];</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://poetries1.gitee.io/img-repo/2019/10/215.jpg" alt></p>
<h3 id="2-7-一个hash表的数据结构"><a href="#2-7-一个hash表的数据结构" class="headerlink" title="2.7 一个hash表的数据结构"></a>2.7 一个hash表的数据结构</h3><blockquote>
<p><code>hash</code>表内容</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">struct st_hash_type &#123;</span><br><span class="line">    int (*compare) ();</span><br><span class="line">    int (*hash) ();</span><br><span class="line">&#125;;</span><br><span class="line"> </span><br><span class="line">struct st_table_entry &#123;</span><br><span class="line">    unsigned int hash;</span><br><span class="line">    char *key;</span><br><span class="line">    char *record;</span><br><span class="line">    st_table_entry *next;</span><br><span class="line">&#125;;</span><br><span class="line"> </span><br><span class="line">struct st_table &#123;</span><br><span class="line">    struct st_hash_type *type;</span><br><span class="line">    int num_bins;</span><br><span class="line">/* slot count */</span><br><span class="line">    int num_entries;</span><br><span class="line">/* total number of entries */</span><br><span class="line">    struct st_table_entry **bins;</span><br><span class="line">/* slot */</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<p>脚本如下：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">digraph st2&#123;</span><br><span class="line">  fontname = &quot;Verdana&quot;;</span><br><span class="line">  fontsize = 10;</span><br><span class="line">  rankdir=TB;</span><br><span class="line"> </span><br><span class="line">  node [fontname = &quot;Verdana&quot;, fontsize = 10, color=&quot;skyblue&quot;, shape=&quot;record&quot;];</span><br><span class="line"> </span><br><span class="line">  edge [fontname = &quot;Verdana&quot;, fontsize = 10, color=&quot;crimson&quot;, style=&quot;solid&quot;];</span><br><span class="line"> </span><br><span class="line">  st_hash_type [label=&quot;&#123;&lt;head&gt;st_hash_type|(*compare)|(*hash)&#125;&quot;];</span><br><span class="line">  st_table_entry [label=&quot;&#123;&lt;head&gt;st_table_entry|hash|key|record|&lt;next&gt;next&#125;&quot;];</span><br><span class="line">  st_table [label=&quot;&#123;st_table|&lt;type&gt;type|num_bins|num_entries|&lt;bins&gt;bins&#125;&quot;];</span><br><span class="line"> </span><br><span class="line">  st_table:bins -&gt; st_table_entry:head;</span><br><span class="line">  st_table:type -&gt; st_hash_type:head;</span><br><span class="line">  st_table_entry:next -&gt; st_table_entry:head [style=&quot;dashed&quot;, color=&quot;forestgreen&quot;];</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://poetries1.gitee.io/img-repo/2019/10/216.jpg" alt></p>
<h3 id="2-8-模块的生命周期图"><a href="#2-8-模块的生命周期图" class="headerlink" title="2.8 模块的生命周期图"></a>2.8 模块的生命周期图</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">digraph module_lc&#123;</span><br><span class="line">  rankdir=TB;</span><br><span class="line">  fontname = &quot;Microsoft YaHei&quot;;</span><br><span class="line">  fontsize = 12;</span><br><span class="line"> </span><br><span class="line">  node [fontname = &quot;Microsoft YaHei&quot;, fontsize = 12, shape = &quot;Mrecord&quot;, color=&quot;skyblue&quot;, style=&quot;filled&quot;];</span><br><span class="line">  edge [fontname = &quot;Microsoft YaHei&quot;, fontsize = 12, color=&quot;darkgreen&quot; ];</span><br><span class="line"> </span><br><span class="line">  installed [label=&quot;已安装状态&quot;];</span><br><span class="line">  resolved [label=&quot;已就绪状态&quot;];</span><br><span class="line">  uninstalled [label=&quot;已卸载状态&quot;];</span><br><span class="line">  starting [label=&quot;正在启动&quot;];</span><br><span class="line">  active [label=&quot;已激活(运行)状态&quot;];</span><br><span class="line">  stopping [label=&quot;正在停止&quot;];</span><br><span class="line">  start [label=&quot;&quot;, shape=&quot;circle&quot;, width=0.5, fixedsize=true, style=&quot;filled&quot;, color=&quot;black&quot;];</span><br><span class="line"> </span><br><span class="line">  start -&gt; installed [label=&quot;安装&quot;];</span><br><span class="line">  installed -&gt; uninstalled [label=&quot;卸载&quot;];</span><br><span class="line">  installed -&gt; resolved [label=&quot;准备&quot;];</span><br><span class="line">  installed -&gt; installed [label=&quot;更新&quot;];</span><br><span class="line">  resolved -&gt; installed [label=&quot;更新&quot;];</span><br><span class="line">  resolved -&gt; uninstalled [label=&quot;卸载&quot;];</span><br><span class="line">  resolved -&gt; starting [label=&quot;启动&quot;];</span><br><span class="line">  starting -&gt; active [label=&quot;&quot;];</span><br><span class="line">  active -&gt; stopping [label=&quot;停止&quot;];</span><br><span class="line">  stopping -&gt; resolved [label=&quot;&quot;];</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://poetries1.gitee.io/img-repo/2019/10/217.jpg" alt></p>
<h3 id="2-9-简单的UML类图"><a href="#2-9-简单的UML类图" class="headerlink" title="2.9 简单的UML类图"></a>2.9 简单的UML类图</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">digraph G&#123;</span><br><span class="line"> </span><br><span class="line">  fontname = &quot;Courier New&quot;</span><br><span class="line">  fontsize = 10</span><br><span class="line"> </span><br><span class="line">  node [ fontname = &quot;Courier New&quot;, fontsize = 10, shape = &quot;record&quot; ];</span><br><span class="line">  edge [ fontname = &quot;Courier New&quot;, fontsize = 10 ];</span><br><span class="line"> </span><br><span class="line">  Animal [ label = &quot;&#123;Animal |+ name : String\\l+ age : int\\l|+ die() : void\\l&#125;&quot; ];</span><br><span class="line"> </span><br><span class="line">      subgraph clusterAnimalImpl&#123;</span><br><span class="line">          bgcolor=&quot;yellow&quot;</span><br><span class="line">          Dog [ label = &quot;&#123;Dog||+ bark() : void\\l&#125;&quot; ];</span><br><span class="line">          Cat [ label = &quot;&#123;Cat||+ meow() : void\\l&#125;&quot; ];</span><br><span class="line">      &#125;;</span><br><span class="line"> </span><br><span class="line">  edge [ arrowhead = &quot;empty&quot; ];</span><br><span class="line"> </span><br><span class="line">  Dog-&gt;Animal;</span><br><span class="line">  Cat-&gt;Animal;</span><br><span class="line">  Dog-&gt;Cat [arrowhead=&quot;none&quot;, label=&quot;0..*&quot;];</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://poetries1.gitee.io/img-repo/2019/10/218.jpg" alt></p>
<h3 id="2-10-有限状态机"><a href="#2-10-有限状态机" class="headerlink" title="2.10 有限状态机"></a>2.10 有限状态机</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">digraph finite_state_machine &#123;</span><br><span class="line">    rankdir=LR;</span><br><span class="line">    size=&quot;8,5&quot;</span><br><span class="line">    node [shape = circle];</span><br><span class="line">    S0 -&gt; S1 [ label = &quot;Lift Nozzle&quot; ]</span><br><span class="line">    S1 -&gt; S0 [ label = &quot;Replace Nozzle&quot; ]</span><br><span class="line">    S1 -&gt; S2 [ label = &quot;Authorize Pump&quot; ]</span><br><span class="line">    S2 -&gt; S0 [ label = &quot;Replace Nozzle&quot; ]</span><br><span class="line">    S2 -&gt; S3 [ label = &quot;Pull Trigger&quot; ]</span><br><span class="line">    S3 -&gt; S2 [ label = &quot;Release Trigger&quot; ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="http://img2.tuicool.com/yEze6z.png%21web" alt></p>
<h2 id="三、语法"><a href="#三、语法" class="headerlink" title="三、语法"></a>三、语法</h2><blockquote>
<p>完整列表 <a href="http://graphviz.org/doc/info/attrs.html" target="_blank" rel="noopener">http://graphviz.org/doc/info/attrs.html</a></p>
</blockquote>
<h3 id="3-1-图像属性"><a href="#3-1-图像属性" class="headerlink" title="3.1 图像属性"></a>3.1 图像属性</h3><ul>
<li><code>label=&quot;My Graph&quot;;</code>       给图像设置标签</li>
<li><code>rankdir=LR</code>;             将图片由原来的从上到下布局变成从左到右布局</li>
<li><code>{rank=same; a, b, c }</code>   将一组元素放到同一个<code>level</code></li>
<li><code>splines=&quot;line&quot;</code>;         让边框变为直线，没有曲线和锐角</li>
<li><code>K=0.6</code>;      用来在布局中影响<code>spring</code>属性，<code>spring</code>属性可以用于将节点往外推，这个在<code>twopi</code>和<code>sfdp</code>布局中很有用。</li>
</ul>
<h3 id="3-2-交点属性"><a href="#3-2-交点属性" class="headerlink" title="3.2 交点属性"></a>3.2 交点属性</h3><ul>
<li><code>[label=&quot;Some Label&quot;]</code>    给交点打标签</li>
<li><code>[color=&quot;red&quot;]</code>         给交点上色</li>
<li><code>[fillcolor=&quot;blue&quot;]</code>      设置交点的填充色</li>
</ul>
<h3 id="3-3-边的属性"><a href="#3-3-边的属性" class="headerlink" title="3.3 边的属性"></a>3.3 边的属性</h3><ul>
<li><code>[label=&quot;Some Label&quot;]</code>    给边设置标签 (设置路径权重的时候很有用)</li>
<li><code>[color=&quot;red&quot;]</code>          # 给交点上色 (标示路径的时候很有用)</li>
<li><code>[penwidth=2.0]</code>          # 给边适配厚度，标示路径的时候很有用。</li>
</ul>
<h3 id="3-4-尺寸-背景颜色"><a href="#3-4-尺寸-背景颜色" class="headerlink" title="3.4 尺寸, 背景颜色"></a>3.4 尺寸, 背景颜色</h3><ul>
<li><code>fixedsize=true</code>;</li>
<li><code>size=&quot;1,1&quot;</code>;</li>
<li><code>resolution=72</code>;</li>
<li><code>bgcolor=&quot;#C6CFD532&quot;</code>;</li>
</ul>
<h2 id="四、一些技巧"><a href="#四、一些技巧" class="headerlink" title="四、一些技巧"></a>四、一些技巧</h2><h3 id="4-1-插入图片"><a href="#4-1-插入图片" class="headerlink" title="4.1 插入图片"></a>4.1 插入图片</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">digraph &#123;</span><br><span class="line"></span><br><span class="line">    c[shape = none, image = &quot;./pic.png&quot;]</span><br><span class="line">    a -&gt; b -&gt; c;</span><br><span class="line">    c -&gt; d;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://poetries1.gitee.io/img-repo/2019/10/219.jpg" alt></p>
<blockquote>
<p>注：需要用命令行<code>dot test.dot -T png -o test.png</code>生成，前提是用<code>brew</code>安装了<code>GraphViz</code></p>
</blockquote>
<h3 id="4-2-统一节点和连线"><a href="#4-2-统一节点和连线" class="headerlink" title="4.2 统一节点和连线"></a>4.2 统一节点和连线</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">digraph &#123;</span><br><span class="line"></span><br><span class="line">    node[color = Red, fontsize = 24, shape = box]</span><br><span class="line">    edge[color = Blue, style = &quot;dashed&quot;]</span><br><span class="line"></span><br><span class="line">    c[shape = none, image = &quot;./pic.png&quot;]</span><br><span class="line">    a -&gt; b -&gt; c;</span><br><span class="line">    c -&gt; d;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://poetries1.gitee.io/img-repo/2019/10/220.jpg" alt></p>

      </div>
    
  </div>

</article>

<button class="assist-btn2 circle" id="assist_btn2" title="点亮屏幕" style="left: 27px; top: 152px;">
  <i class="iconfont" style="display:inline-block;color:red;width:20px;height:20px;">&#xe61d;</i>
</button>
<button class="assist-btn1 circle" id="assist_btn1" title="关闭屏幕亮度" style="left: 27px; top: 152px;">
  <i class="iconfont toc-title" style="display:inline-block;color:red;width:20px;height:20px;">&#xe61d;</i>
</button>


<script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>	

<script src="https://my.openwrite.cn/js/readmore.js" type="text/javascript"></script>
<script>
  const btw = new BTWPlugin();
  btw.init({
    id: "container",
    blogId: "22699-1592137983091-414",
    name: "前端进阶之旅",
    qrcode: "https://poetries1.gitee.io/img-repo/2020/06/qrcode.jpg",
    keyword: "3a3b3c",
  });
</script>

<script type="text/javascript">

// white theme
var body = {color: "#555", background: "#000"};
var a_tag = {color: "#222"};
var header = { background: "#222"};
var logo_line_i = {background: "#222"};
// var post_code = {background: "#eee", color: "#222"};

function switch_theme() {
 $("body").css(body);
 $("a:not('.links-of-author-item a, .site-state-item a, .site-state-posts a, .feed-link a, .motion-element a, .post-tags a, .show-commit-cls a, #donate_board a')").css(a_tag);
 $(".header, .footer").css(header);
 $(".logo-line-before i, .logo-line-after i").css(logo_line_i);
 //$(".post code").css(post_code);
 $("#idhyt-surprise-ball #idhyt-surprise-ball-animation .drag").css(a_tag);
 $(".post-title-link, .posts-expand .post-meta, .post-comments-count, .disqus-comment-count, .post-category a, .post-nav-next a, .post-nav-item a").css(a_tag);
 
 // $("code").css({color: '#c5c8c6', background: '#1d1f21'});
 //$("#assist_btn1").hide(1500);
}

$(function () {
$("#assist_btn2").css("display","none");
 $("#assist_btn1").click(function() {
     switch_theme();
$("div#toc.toc-article").css({
 "background":"#eaeaea",
 "opacity":1
});
$(".toc-article ol").show();
$("#toc.toc-article .toc-title").css("color","#a98602");
$("#assist_btn1").css("display","none");
$("#assist_btn2").css("display","block");
 });
$("#assist_btn2").click(function() {
$("#assist_btn2").css("display","none");
$("#assist_btn1").css("display","block");
$("body").css("background","url(http://www.miaov.com/static/ie/images/news/bg.png)")
     $(".header, .footer").css("background","url(http://www.miaov.com/static/ie/images/news/bg.png)")
$(".toc-article ol").toggle(1000);
 });
});


//背景随机

var Y, O, E, L, B, C, T, z, N, S, A, I;
!function() {
var e = function() {
for (O.clearRect(0, 0, L, B), T = [{
x: 0,
y: .7 * B + C
}, {
x: 0,
y: .7 * B - C
}]; T[1].x < L + C;) t(T[0], T[1])
}, t = function(e, t) {
O.beginPath(), O.moveTo(e.x, e.y), O.lineTo(t.x, t.y);
var n = t.x + (2 * I() - .25) * C,
 r = a(t.y);
O.lineTo(n, r), O.closePath(), N -= S / -50, O.fillStyle = "#" + (127 * A(N) + 128 << 16 | 127 * A(N + S / 3) + 128 << 8 | 127 * A(N + S / 3 * 2) + 128).toString(16), O.fill(), T[0] = T[1], T[1] = {
 x: n,
 y: r
}
}, a = function n(e) {
var t = e + (2 * I() - 1.1) * C;
return t > B || t < 0 ? n(e) : t
};
Y = document.getElementById("evanyou"), O = Y.getContext("2d"), E = window.devicePixelRatio || 1, L = window.innerWidth, B = window.innerHeight, C = 90, z = Math, N = 0, S = 2 * z.PI, A = z.cos, I = z.random, Y.width = L * E, Y.height = B * E, O.scale(E, E), O.globalAlpha = .6, document.onclick = e, document.ontouchstart = e, e()
}()

   
$("#toc-eye").click(function(){
$("#toc.toc-article").toggle(1000);
});

</script>


   
  <div class="text-center donation">
    <div class="inner-donation">
      <span class="btn-donation">支持一下</span>
      <div class="donation-body">
        <div class="tip text-center">扫一扫，支持poetries</div>
        <ul>
        
          <li class="item">
            
              <span>微信扫一扫</span>
            
            <img src="/images/weixin.jpg" alt="">
          </li>
        
          <li class="item">
            
              <span>支付宝扫一扫</span>
            
            <img src="/images/zhifubao.jpg" alt="">
          </li>
        
        </ul>
      </div>
    </div>
  </div>


   
  <div class="box-prev-next clearfix">
    <a class="show pull-left" href="/2018/09/16/ant-design-pro/">
        <i class="icon icon-angle-left"></i>
    </a>
    <a class="show pull-right" href="/2018/10/19/goods-app-summary/">
        <i class="icon icon-angle-right"></i>
    </a>
  </div>




</div>


  <a id="backTop" class="back-top">
    <i class="icon-angle-up"></i>
  </a>




  <div class="modal" id="modal">
  <span id="cover" class="cover hide"></span>
  <div id="modal-dialog" class="modal-dialog hide-dialog">
    <div class="modal-header">
      <span id="close" class="btn-close">关闭</span>
    </div>
    <hr>
    <div class="modal-body">
      <ul class="list-toolbox">
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/archives/"
              rel="noopener noreferrer"
              target="_self"
              >
              博客
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/categories/"
              rel="noopener noreferrer"
              target="_self"
              >
              分类
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/tags/"
              rel="noopener noreferrer"
              target="_self"
              >
              标签
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/search/"
              rel="noopener noreferrer"
              target="_self"
              >
              搜索
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/link/"
              rel="noopener noreferrer"
              target="_self"
              >
              友链
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/about/"
              rel="noopener noreferrer"
              target="_self"
              >
              关于
            </a>
          </li>
        
      </ul>

    </div>
  </div>
</div>



  
      <div class="fexo-comments comments-post">
    

    

    
    

    

    
    

    

<!-- Gitalk评论插件通用代码 -->
<div id="gitalk-container"></div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
<script>
const gitalk = new Gitalk({
  clientID: '5567a2c4abb858009d96',
  clientSecret: 'b9039ec056cf5c2346b3cdb63308a28c163f91e5',
  repo: 'poetries.github.io',
  owner: 'poetries',
  // 在这里设置一下截取前50个字符串, 这是因为 github 对 label 的长度有了要求, 如果超过
  // 50个字符串则会报错.
  // id: location.pathname.split('/').pop().substring(0, 49),
  id: location.pathname,
  admin: ['poetries'],
  // facebook-like distraction free mode
  distractionFreeMode: false
})
gitalk.render('gitalk-container')
</script>
<!-- Gitalk代码结束 -->



  </div>

  

  <script type="text/javascript">
  function loadScript(url, callback) {
    var script = document.createElement('script')
    script.type = 'text/javascript';

    if (script.readyState) { //IE
      script.onreadystatechange = function() {
        if (script.readyState == 'loaded' ||
          script.readyState == 'complete') {
          script.onreadystatechange = null;
          callback();
        }
      };
    } else { //Others
      script.onload = function() {
        callback();
      };
    }

    script.src = url;
    document.getElementsByTagName('head')[0].appendChild(script);
  }

  window.onload = function() {
    loadScript('/js/bundle.js?235683', function() {
      // load success
    });
  }
</script>


  <!-- 页面点击小红心 -->
  <script type="text/javascript" src="/js/clicklove.js"></script>
 
  
</body>
</html>
